package lab03.test07;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

/**
 * Created by lenovo on 2017/11/17.
 */
public class Test {
    public static void main(String[] args) {
//        7、	读取book.zip,并将book.zip中含有的文件重新存放到当前目录中的book文件夹中，
//        即将book.zip的内容解压到book文件夹中。
        String path = "F:\\book.zip";
        ZipInputStream zipInputStream = null;
        try {
            zipInputStream = new ZipInputStream(new FileInputStream(path));
            //entry：压缩包中的信息
            ZipEntry entry;
            while ((entry = zipInputStream.getNextEntry()) != null) {
                System.out.println(entry.getName());
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                zipInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}